<?php

include '../../configs/global.php';
$data = $_POST;
$cname = $data['cname'];
$credit = $data['credit'];
$info=$data['info'];
//定义一个返回数组
$ajax_res = array();

$sql="select * from curriculum where cname='$cname'";

	$row=$pdo->getOne($sql);

if(!$row){
	$sql="insert into curriculum(cname,credit,info) values('{$cname}','{$credit}','{$info}')";
	$r1=$pdo->exec($sql);
	if($r1){
        header('location:/study/style/skip.php?url=admin/showcurriculum.php&info=添加成功！');
	}else{
        header('location:/study/style/skip.php?url=admin/showcurriculum.php&info=添加失败,请稍后再试!');
	}
}else{
    header('location:/study/style/skip.php?url=admin/showcurriculum.php&info=课程已存在！');
}
// echo json_encode($ajax_res);